/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.subway.persistencias;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "producto", catalog = "bd_subway", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Producto.findAll", query = "SELECT p FROM Producto p"),
    @NamedQuery(name = "Producto.findByProdId", query = "SELECT p FROM Producto p WHERE p.prodId = :prodId"),
    @NamedQuery(name = "Producto.findByProdNombre", query = "SELECT p FROM Producto p WHERE p.prodNombre = :prodNombre"),
    @NamedQuery(name = "Producto.findByProdCantidad", query = "SELECT p FROM Producto p WHERE p.prodCantidad = :prodCantidad")})
public class Producto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "prodId")
    private Integer prodId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "prodNombre", nullable = false, length = 40)
    private String prodNombre;
    @Basic(optional = false)
    @NotNull
    @Column(name = "prodCantidad", nullable = false)
    private int prodCantidad;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "regPedProdId")
    private List<PedidoRegistro> pedidoRegistroList;
    @JoinColumn(name = "prodCategoriaId", referencedColumnName = "catId", nullable = false)
    @ManyToOne(optional = false)
    private ProdCategoria prodCategoriaId;

    public Producto() {
    }

    public Producto(Integer prodId) {
        this.prodId = prodId;
    }

    public Producto(Integer prodId, String prodNombre, int prodCantidad) {
        this.prodId = prodId;
        this.prodNombre = prodNombre;
        this.prodCantidad = prodCantidad;
    }

    public Integer getProdId() {
        return prodId;
    }

    public void setProdId(Integer prodId) {
        this.prodId = prodId;
    }

    public String getProdNombre() {
        return prodNombre;
    }

    public void setProdNombre(String prodNombre) {
        this.prodNombre = prodNombre;
    }

    public int getProdCantidad() {
        return prodCantidad;
    }

    public void setProdCantidad(int prodCantidad) {
        this.prodCantidad = prodCantidad;
    }

    @XmlTransient
    public List<PedidoRegistro> getPedidoRegistroList() {
        return pedidoRegistroList;
    }

    public void setPedidoRegistroList(List<PedidoRegistro> pedidoRegistroList) {
        this.pedidoRegistroList = pedidoRegistroList;
    }

    public ProdCategoria getProdCategoriaId() {
        return prodCategoriaId;
    }

    public void setProdCategoriaId(ProdCategoria prodCategoriaId) {
        this.prodCategoriaId = prodCategoriaId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (prodId != null ? prodId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Producto)) {
            return false;
        }
        Producto other = (Producto) object;
        if ((this.prodId == null && other.prodId != null) || (this.prodId != null && !this.prodId.equals(other.prodId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.prodNombre;
    }
    
}
